//
//  VisitorTableViewController.swift
//  weibo
//
//  Created by 黄龙飞 on 15/11/22.
//  Copyright © 2015年 黄龙飞. All rights reserved.
//

import UIKit

class VisitorTableViewController: UITableViewController {
private var userLogon=UserAccountViewModel().userLogon
    var visitorview:visitorView?
    override func loadView() {
        print("come here")
        //
        userLogon ? super.loadView():setupVisitorView()
        }
    
    private func setupVisitorView(){
        visitorview=visitorView()
        view=visitorview
        visitorview?.registerButton.addTarget(self, action: "visitorViewDidRegister", forControlEvents: .TouchUpInside)
        visitorview?.loginButton.addTarget(self, action: "visitorViewDidLogin", forControlEvents: .TouchUpInside)
        
//        view.backgroundColor=UIColor.orangeColor()
        navigationItem.leftBarButtonItem=UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorViewDidRegister")
        navigationItem.rightBarButtonItem=UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorViewDidLogin")
    }
}
extension VisitorTableViewController{
    func visitorViewDidRegister(){
    print("注册")
    }
    func visitorViewDidLogin(){
    print("登录")
        let vc=OAuthViewController()
        let nav=UINavigationController(rootViewController: vc)
        presentViewController(nav, animated: true, completion: nil)
    }
}
